/**
 * Created by wangxiaoqiang on 2017/8/19.
 */
    let wxqUI = {
        menuCli:function (_this) {
            let direct = $(_this[0].children[1]);
            if(_this.hasClass("active")){
                _this.removeClass("active");
                $(_this[0].nextElementSibling).hide(300);
                if(direct){
                    direct.removeClass("fa-angle-down");
                    direct.addClass("fa-angle-right")
                }
                return
            }
            if(direct){
                direct.removeClass("fa-angle-right");
                direct.addClass("fa-angle-down")
            }
            _this.addClass("active");
            $(_this[0].nextElementSibling).show(300)
        },
        getUrlParam : function (name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            let r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r !== null) return unescape(r[2]); return null; //返回参数值
        },
        tabSwitch:function (tab_title) {
            for (let i = 0; i< tab_title.length;i++){
                if ($(tab_title[i]).hasClass("tab-active")){
                    current = i
                }
            }
            tab_title.hover(function () {
                if(tab_title.hasClass("tab-active")){
                    tab_title.removeClass("tab-active")
                }
                $(this).addClass("tab-active")
            },function () {
                if(tab_title.hasClass("tab-active")){
                    tab_title.removeClass("tab-active")
                }
                $($(tab_title[current]).addClass("tab-active"))
            })
        },
        tabClick:function(tab_title,tab_item){
            tab_title.click(function () {
                if(tab_item.hasClass("tab-item-active")){
                    tab_item.removeClass("tab-item-active");
                }
                current = $(this)[0].dataset.index;
                $(tab_item[current]).addClass("tab-item-active")
            })
        }
    };

    //menu click to select
    (function () {
        $(".menu>li>a").on("click",function () {
            let _this = $(this);
            wxqUI.menuCli(_this)
        })
    })(wxqUI)

